package com.hotel.reservation.service.impl;

import com.hotel.reservation.dao.ManageDao;
import com.hotel.reservation.dao.UserDao;
import com.hotel.reservation.po.Manage;
import com.hotel.reservation.po.Message;
import com.hotel.reservation.po.User;
import com.hotel.reservation.service.ManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class ManageServiceImpl implements ManageService {

    @Autowired
    private ManageDao manageDao;
    @Autowired
    private UserDao userDao;

    @Override
    public List<Manage> adminLogin(Manage manage) {
        return manageDao.adminLogin(manage);
    }

    @Override
    public int adminAdd(Manage manage) {
        return  manageDao.addManage(manage);
    }

    @Override
    public int deleteManage(int id) {
        return manageDao.deleteManage(id);
    }

    @Override
    public List<User> showUser() {
        return userDao.findAllUser();
    }

    @Override
    public int userAdd(User user) {
        if (userDao.findOneUserByTel(user.getUserTel()).size()!=0)
            return -1;
        userDao.addUser(user);
            return 1;
    }

    @Override
    public List<Manage> showManage() {
        return manageDao.showManage();
    }

    @Override
    public List<Manage> selectAllManageByPage(Map map) {
        return manageDao.selectAllManageByPage(map);
    }

    @Override
    public int updateManageById(Manage manage) {
        return manageDao.updateManageById(manage);
    }

    @Override
    public List<Manage> findOneManage(int id) {
        return manageDao.findOneManage(id);
    }

    @Override
    public List<Message> findOneMessage(int id) {
        return manageDao.findOneMessage(id);
    }

    @Override
    public List<Message> showMessage() {
        return manageDao.showMessage();
    }

    @Override
    public List<Message> selectMessageByPage(Map map) {
        return manageDao.selectMessageByPage(map);
    }

    @Override
    public int updateMessage(Message message) {

        return manageDao.updateMessage(message);
    }

    @Override
    public int deleteMessage(int id) {
        return manageDao.deleteMessage(id);
    }
}
